<?php

class Login extends Controller {

    public function __construct() {
        parent::__construct();

        $this->view->js_desktop[0] = URL . 'public/js/jquery_min.js';
        $this->view->js_desktop[1] = URL . 'public/js/jquery_ui_min.js';
        $this->view->js_desktop[2] = URL . 'public/js/sendmessage.js';        
        $this->view->js_desktop[5] = URL . 'public/js/slide.js';
        $this->view->js_desktop[6] = URL . 'public/js/equalheights.js';
        
        $this->view->css_desktop[0] = URL . 'public/css/default.css';
        $this->view->css_desktop[1] = URL . 'public/css/picklist.css';
        $this->view->css_desktop[2] = URL . 'public/css/slide.css';
        
        $this->view->css_mobile[0] = 'http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.css';
        $this->view->js_mobile[0] = URL . 'public/js/jquery_min_1_5_2.js';
        $this->view->js_mobile[1] = URL . 'public/js/jquery_mobile.js';
        $this->view->js_mobile[2] = URL . 'public/js/m_login.js';
        
        }

    public function index() {
        if(UserAccess::GetMobileViewer())
            $this->view->render('mobile/login/index');
        else
            $this->view->render('desktop/login/index');
    }

    function login() {
        $this->model->Userlogin();
    }

    function logout() {
        UserAccess::clearsessionscookies();
        if(UserAccess::GetMobileViewer())
            $this->view->render('mobile/login/index');
        else
            header('location: ../login');
        exit;
    }

    function register() {
        $this->model->UserRegister();
    }

    function changepassword() {
        $this->model->ChangePassword();
    }

    function mobileviewer() {
        $this->model->SetMobileViewer();
    }

    function desktopviewer() {
        $this->model->SetDesktopViewer();
    }
}